fix(knowledge): apply knowledge-base access checks consistently across auth types - #6426
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryHigh Risk Overview GET now requires an acting KB tag schema enrichers now receive Route and enricher tests cover session vs internal JWT, granted/denied/not-found, and missing acting user. Reviewed by Cursor Bugbot for commit 3419e4f. Configure here. |
Greptile SummaryThis PR consistently authorizes knowledge-base tag-definition requests using the acting user and propagates that identity through tool-schema enrichment.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| apps/sim/app/api/knowledge/[id]/tag-definitions/route.ts | Applies acting-user authorization consistently, using read access for GET and write access for POST. |
| apps/sim/app/api/knowledge/[id]/tag-definitions/route.test.ts | Covers session and internal-JWT authorization outcomes, with the previously requested readonly fixture assertions present. |
| apps/sim/tools/params.ts | Passes workflow execution context to parameter-level schema enrichers. |
| apps/sim/tools/schema-enrichers.ts | Uses the acting user when requesting KB tag definitions and safely skips enrichment when that identity is absent. |
| apps/sim/tools/schema-enrichers.test.ts | Verifies acting-user header propagation and identity-less enrichment behavior. |
| apps/sim/tools/types.ts | Extends the parameter schema-enrichment contract with workflow execution context. |
Sequence Diagram
sequenceDiagram
participant Tool as Workflow Tool
participant Enricher as KB Schema Enricher
participant Auth as Internal Auth Builder
participant Route as Tag Definitions Route
participant Access as KB Access Check
participant Tags as Tag Service
Tool->>Enricher: Enrich schema (KB ID, execution context)
alt Acting user is present
Enricher->>Auth: Build headers for user ID
Auth-->>Enricher: Internal JWT headers
Enricher->>Route: GET tag definitions
Route->>Access: Check read access for acting user
alt Access granted
Access-->>Route: Allowed
Route->>Tags: Get tag definitions
Tags-->>Route: Definitions
Route-->>Enricher: 200 with definitions
Enricher-->>Tool: Enriched schema
else Access denied
Access-->>Route: Forbidden or not found
Route-->>Enricher: 403 or 404
Enricher-->>Tool: No enrichment
end
else Acting user is absent
Enricher-->>Tool: Skip enrichment
end
Reviews (2): Last reviewed commit: "chore(tests): mark tag-definition test f..." | Re-trigger Greptile
…s auth types The tag-definitions route only ran its knowledge-base access check for browser sessions, skipping it for internal JWT callers. Authorize on the acting user for every auth type instead — read access for GET, write access for POST — and require an acting user to be present, matching the sibling knowledge routes. Thread the acting user through the KB tag schema enrichers so their request carries the identity the route now authorizes.
7c47366 to
3419e4f
Compare
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 3419e4f. Configure here.
Summary
/api/knowledge/[id]/tag-definitions, instead of only for browser sessionsGETand write access forPOST, matching the sibling knowledge routesType of Change
Testing
Added route tests covering both auth types and the granted/denied/not-found/no-acting-user paths, plus enricher tests. Verified each new test fails against the previous behavior. Full
app/api/knowledge+ tools suites pass (550 tests),type-check,lint:check, andcheck:api-validation:strictclean.Checklist